"""
@Date:2022/8/5
@author:Jingyu
@Description：长春安全 - 法律法规 查询与排序的执行层
@other：
"""
import time

from base.LoginAndQuit import TestStart
from base.Menu import Menu
from service.smsLaw.SmsLawByRead import SmsLawByRead
from service.smsLaw.SmsLawByAdd import SmsLawByAdd
# 法律法规执行
if __name__ == '__main__':
    # 登录
    login = TestStart()
    driver = login.loadDriver()
    login.loadLogin(driver, 'http://10.10.10.120:30207/', 'administrator', "Gdjt@2021")
    # 进入菜单
    menu = Menu()
    menu.clickMenu(driver, '/html/body/div[1]/section/section/aside/div[1]/ul', '法律法规')
    # 搜索框查询
    smsLawByRead = SmsLawByRead()
    smsLawByRead.selectRead(driver, '//*[@id="sname"]', '测试01')
    # 表头input搜索
    smsLawByRead.liReadByInput(driver, 5, '名称')
    # 表头下拉框搜索
    smsLawByRead.liReadByOption(driver, '/html/body/div[3]/div/div/div/ul', '有效')
    # 指定排序
    smsLawByRead.sortById(driver, 3)
    # 全部排序
    smsLawByRead.sortAll(driver, 8)
    time.sleep(10)

# 新增
if __name__ == '__main__':
    login = TestStart()
    driver = login.loadDriver()
    login.loadLogin(driver, 'http://10.10.10.120:30207/', 'administrator', "Gdjt@2021")
    menu = Menu()
    menu.clickMenu(driver, '/html/body/div[1]/section/section/aside/div[1]/ul', '法律法规')
    # ---------新增-----------
    smsLawByAdd = SmsLawByAdd()
    # 元素添加
    title = {'sfgno':'webTest001','sfgname':'webTest001','deffective':'2022-08-09','option':{'xpath':'//*[@id="istatus"]/div/div/div[1]'
                                                          ,'ulXpath':'/html/body/div[5]/div/div/div/ul','text':'有效'},'option2':{'xpath':'//*[@id="imajor"]/div/div/div[1]','ulXpath':'/html/body/div[5]/div/div/div/ul','text':'消防'},'save':'/html/body/div[3]/div/div[2]/div/div[2]/div[2]/div/div/div/div/div/div/div/div[1]/div/div/div/div/span/button'}
    smsLawByAdd.add(driver,title)
    smsLawByAdd.titleOption(driver,title)


